import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import RegisterView from '@/views/RegisterView.vue'
import AboutView from '@/views/AboutView.vue'
import ArticleList from '@/views/article/list.vue'
import ArticleDetail from '@/views/article/detail.vue'
import QuestionList from '@/views/question/list.vue'
import QuestionDetail from '@/views/question/detail.vue'
import SearchList from '@/views/search/list.vue'
import ScoreQuery from '@/views/score/query.vue'
import ScoreList from '@/views/score/list.vue'
import ScoreDetail from '@/views/score/detail.vue'
import Login from '@/views/Login.vue'

// createRouter 创建路由实例，===> new VueRouter()
// history 是路由模式，hash模式，history模式
// createWebHistory() 是开启history模块   http://xxx/user
// createWebHashHistory() 是开启hash模式    http://xxx/#/user

// vite 的配置 import.meta.env.BASE_URL 是路由的基准地址，默认是 ’/‘
// https://vitejs.dev/guide/build.html#public-base-path
// 如果将来你部署的域名路径是：http://xxx/my-path/user
// vite.config.ts  添加配置  base: my-path，路由这就会加上 my-path 前缀了

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/home',
      name: 'home',
      component: HomeView
    },
    {
      path: '/register',
      name: 'register',
      component: RegisterView
    },
    {
      path: '/about',
      name: 'about',
      component: AboutView
    },
    {
      path: '/article-list',
      name: 'ArticleList',
      component: ArticleList
    },
    {
      path: '/article-detail',
      name: 'ArticleDetail',
      component: ArticleDetail
    },
    {
      path: '/question-list',
      name: 'QuestionList',
      component: QuestionList
    },
    {
      path: '/question-detail',
      name: 'QuestionDetail',
      component: QuestionDetail
    },
    {
      path: '/search-list',
      name: 'SearchList',
      component: SearchList
    },
    { path: '/score-query', name: 'ScoreQuery', component: ScoreQuery },
    { path: '/score-list', name: 'ScoreList', component: ScoreList },
    { path: '/score-detail/:index', name: 'ScoreDetail', component: ScoreDetail },
    {path: '/', component: Login}
  ]
})

export default router
